{# SPDX-License-Identifier: Apache-2.0 -#}

{% set project_name = project.normalized_name %}

<form action="{{ request.route_path('admin.project.delete', project_name=project_name) }}" method="POST">
  <input name="csrf_token" type="hidden" value="{{ request.session.get_csrf_token() }}">

  <div class="card card-danger collapsed-card">
    <div class="card-header">
      <h3 class="card-title">Delete / Quarantine Project</h3>
      <div class="card-tools">
        <button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas fa-plus"></i></button>
      </div>
    </div>

    <div class="card-body">
      <p>
        Deleting will irreversibly delete this project along with
        <a href="{{ request.route_path('admin.project.releases', project_name=project_name) }}">{{ project.releases|length() }} releases</a>.
        Consider Quarantine if you want to keep the project but make it unavailable.
      </p>
      <div class="form-group col-sm-12">
        <label for="confirm_project_name">
          Are you sure you want to delete <strong>{{ project_name }}</strong>?
        </label>
        <input name="confirm_project_name" id="confirm_project_name" class="form-control" type="text" placeholder="Enter project name to confirm" {{ "disabled" if not request.has_permission(Permissions.AdminProjectsDelete) }} autocomplete="off" autocorrect="off" autocapitalize="off">
      </div>
    </div>

    <div class="card-footer">
      <div class="float-left">
        <button type="button"
                class="btn btn-block btn-outline-warning"
                data-toggle="modal"
                data-target="#modal-quarantine">Quarantine Project</button>
      </div>
      <div class="float-right">
        <button type="submit" class="btn btn-primary" title="{{ 'Deleting requires superuser privileges' if not request.has_permission(Permissions.AdminProjectsDelete) }}" {{ "disabled" if not request.has_permission(Permissions.AdminProjectsDelete) }}>Confirm</button>
      </div>
    </div>
  </div>
</form>

<div class="modal fade" id="modal-quarantine">
  <div class="modal-dialog modal-quarantine">
    <form id="quarantine"
          action="{{ request.route_path('admin.malware_reports.project.verdict_quarantine', project_name=project_name) }}"
          method="post">
      <input name="csrf_token"
             type="hidden"
             value="{{ request.session.get_csrf_token() }}">
      <div class="modal-content">
        <div class="modal-header bg-warning">
          <h4 class="modal-title">Quarantine Project</h4>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">×</span>
          </button>
        </div>
        <div class="modal-body">
          <p>
            Confirming that <code>{{ project_name }}</code> needs further examination.
          </p>
          <p>
            This will remove the Project from being installable,
            and prohibit the Project from being changed by the Owner.
          </p>
        </div>
        <div class="modal-footer justify-content-between">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          <button type="submit" class="btn btn-warning">Verdict: Quarantine Project</button>
        </div>
      </div>
    </form>
  </div>
</div>
<!-- /.modal -->
